package com.SinaMicrobloggingApi.Core.Response;

import com.SinaMicrobloggingApi.Model.ErrorModel;
import com.SinaMicrobloggingApi.Model.UserInfoModel;
import com.Util.Cache.ICache;
import com.Util.Cache.SimpleCache;
import com.google.gson.Gson;

public abstract class ResponseBase implements IResponse {
	protected String oauthToken;
	protected String oauthTokenSecret;
	protected final static ICache cache;
	final static String ERROR_CODE = "error_code";
	protected ErrorModel errorModel;
	static {
		cache = new SimpleCache();
	}

	public String getOauthToken() {
		return oauthToken;
	}

	public void setOauthToken(String oauthToken) {
		this.oauthToken = oauthToken;
	}

	public String getOauthTokenSecret() {
		return oauthTokenSecret;
	}

	public void setOauthTokenSecret(String oauthTokenSecret) {
		this.oauthTokenSecret = oauthTokenSecret;
	}

	// {"request":"/direct_messages.json","error_code":"400","error":"40070:Error: limited application access api!"}

	public void ParseResult(String result) {
		if (result.contains(ERROR_CODE)) {
			Gson gson = new Gson();
			errorModel = gson.fromJson(result, ErrorModel.class);
		}
	}
}
